package aqiyi;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author habitplus
 * @since 2021-08-22 16:41
 */
public class T2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t;
        List<Integer> list = new ArrayList<>();
        while (sc.hasNext()) {
            t = sc.nextInt();
            list.add(t);
        }

        int n = list.size();
        if (n <= 0) {
            System.out.println("0");
            return;
        }

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = list.get(i);
        }


        // 先求最长上升子序列
        int min = 0, max = 0, ans = 0;
        for (int i = 1; i < n; i++) {
            if (arr[i - 1] < arr[i]) {
                max = i;
                continue;
            }
            ans = Math.max(arr[max] - arr[min], ans);
            max = i;
            min = i;
        }

        ans = Math.max(arr[max] - arr[min], ans);
        min = 0;
        max = 0;
        for (int i = 1; i < n; i++) {
            if (arr[i - 1] > arr[i]) {
                max = i;
                continue;
            }
            ans = Math.max(arr[min] - arr[max], ans);
            max = i;
            min = i;
        }

        ans = Math.max(arr[min] - arr[max], ans);

        System.out.println(ans);
    }
}
